package net.zzy.pbbot.plugin.spicyGirl.api;

import lombok.SneakyThrows;
import net.lz1998.pbbot.bot.Bot;
import net.lz1998.pbbot.bot.BotPlugin;
import net.lz1998.pbbot.utils.Msg;
import onebot.OnebotEvent;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Component;

import static net.zzy.pbbot.finalfield.Api.SPICY_GIRL_URL;
import static net.zzy.pbbot.finalfield.Command.SPICY_GIRL;

/**
 * @author zhuZhaoYang
 * @date 2021/9/24 18:45
 */
@Component
public class SpicyGirl extends BotPlugin {

    @SneakyThrows
    @Override
    public int onPrivateMessage(@NotNull Bot bot, @NotNull OnebotEvent.PrivateMessageEvent event) {
        String rawMessage = event.getRawMessage();
        if (!rawMessage.startsWith(SPICY_GIRL)) {
            return MESSAGE_IGNORE;
        }
        Msg.builder().image(SPICY_GIRL_URL).sendToFriend(bot, event.getUserId());
        return MESSAGE_IGNORE;
    }

    @Override
    public int onGroupMessage(@NotNull Bot bot, @NotNull OnebotEvent.GroupMessageEvent event) {
        String rawMessage = event.getRawMessage();
        if (!rawMessage.startsWith(SPICY_GIRL)) {
            return MESSAGE_IGNORE;
        }
        Msg.builder().image(SPICY_GIRL_URL).sendToGroup(bot, event.getGroupId());
        return MESSAGE_IGNORE;
    }
}
